from flask import Blueprint,render_template,request,current_app

bp = Blueprint('test', __name__,
               template_folder='templates',
               static_folder='static')

@bp.route('/ping')
def ping():
    return 'pong'

@bp.route('/')
def index():
    return render_template('test_index.html', domain=request.url)

@bp.route('/<something>')
def hello(something):
    return render_template('hello.html', sth=something)

@bp.route('/foo')
def foo():
    return render_template('test_foo.html')

@bp.route('/bar')
def bar():
    return render_template('test_bar.html')

@bp.route('/dict/<text>')
def split(text):
    text_list = text.split(',')
    dict_var = dict()
    for item in text_list:
        dict_var[item[0]] = item
    current_app.logger.debug(dict_var)
    return render_template('test_dict.html', dict_var = dict_var)

@bp.route('/marco/<text>')
def marco(text):
    return render_template('test_marco.html', marco_test_placeholder=text)